1. Field of the Invention
The present invention relates to an image drawing apparatus and method, and particularly to image processing using a Z-buffer method for drawing an object whose transparency changes.
2. Description of the Related Art
In the conventional video game, when an object including multiples polygons is faded-in/faded-out from a screen in accordance with the progress of the game, transparency of polygons that form the object is changed. Unexamined Japanese Patent Publication No. 2001-224846 discloses a method for drawing an object in the case where the transparency of multiple polygons is changed concurrently.
In the case where the object including the multiple polygons is drawn, a Z-buffer method is widely used to carry out a hidden surface removal for displaying the polygon as an image. An α value indicating transparency (it is assumed that the smaller the value is, the higher the transparency becomes in this case) is set to the polygon. In the conventional Z-buffer method, whether a Z value of a polygon placed at a front side overlapping with a polygon placed at a back side is written to a Z-buffer is decided according to a preset writing threshold.
FIGS. 1A to 1D are views each explaining an example of processing according to the conventional Z-buffer method. As illustrated in FIGS. 1A and 1B, it is assumed that a polygon group 701 whose α value is 70 is placed at the front side which is close to the position of the viewpoint and a polygon group 702 whose α value is 80 is placed at the back side which is fax from the position of the viewpoint. The transparency of the polygons 701 and 702 included in the object is changed simultaneously. The α value, which is obtained when the transparency of the polygons 701 and 702 is changed, is hereinafter referred to as a current α value to be distinguished from the originally set α value. It is assumed that the writing threshold is 60.
When the transparency of the object is unchanged, for example, before starting fade-in and after completing fade-out, a rate of change of transparency is set to 100%. When the object becomes completely transparent, for example, before ending fade-out and after starting fade-in, the rate of change of transparency is set to 0%. When the transparency of the object is unchanged, namely, the rate of change of transparency is set to 100%, a current α value of the polygon group 701 is 70×100/100=70 and a current α value of the polygon group 702 is 80×100/100=80.
In the case where the transparency of the object is unchanged, namely, the rate of change of transparency is set to 100%, when the polygon group 701 placed at the front side is first processed, the α value of the polygon group 701 is higher than the writing threshold. As a result, the Z value of the polygon group 701 is written to the Z-buffer and the polygon group 701 is drawn in a frame buffer. When the polygon group 702 placed at the back side is processed after the polygon group 701, the Z value of the polygon group 702 is not written to the Z-buffer since a Z value, which is smaller than the Z value of the polygon group 702, is already written to the Z-buffer. The polygon group 702 is not drawn in the frame buffer. In this case, as illustrated in FIG. 1C, the polygon group 701 placed at the front side is displayed on a display screen and the polygon group 702 placed at the back side is not displayed on the display screen.
However, when the transparency of the object is changed, the following problem occurs. As illustrated in FIG. 1D, when the rate of change of transparency is 80%, the current α value of the polygon group 701 placed at the front side is 56, which is lower than 60 of the writing threshold, and the current α value of the polygon group 702 placed at the back side is 64, which is higher than 60 of the writing threshold.
When the polygon group 701 placed at the front side is processed before the polygon group 702 placed at the back side, the Z value of the polygon group 701, whose current α value is lower than the writing threshold, is not written to the Z-buffer. As a result, the polygon group 702 placed at the back side, whose current α value is higher than the writing threshold, is drawn in the frame buffer. In this case, as illustrated in FIG. 1D, the polygon group 702, which exists at the back side, is displayed at the front side of the polygon group 701 on the display screen.
In order to solve the above problem, it can be considered that all polygons that form a drawing object are sorted in order of decreasing distance from the position of the viewpoint and that the respective polygons are processed in the order in which these polygons are sorted to draw each polygon in the frame buffer. However, sort processing increases an amount of calculations with at least the square order of the number of polygons. In the video game, since an image must be drawn for one frame time, sort processing cannot be completed for one frame when many polygons are processed. When the number of polygons that form the object is reduced, an image of the object displayed on the display screen becomes angular and unnatural.
In order to solve the above problem, there is a technique that determines whether the polygon that is projected on a virtual screen is a surface side or a back surface side and only the polygon determined as being the surface side is written to the frame buffer so that the polygon hidden behind the back surface side is displayed on the display screen. However, extremely large amounts of processing are required to determine whether the surface side or the back surface side is projected on the virtual screen in connection with all polygons.